#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;
const int N = 110, INF = 1e9 + 10;

int n, m;
int g[N][N], d[N][N];
int post[N][N];

void get_path(int i, int j, vector<int> & temp)
{
    if(!post[i][j])
        return;

    int k = post[i][j];
    get_path(i, k, temp);
    temp.push_back(k);
    get_path(k, j, temp);
}

vector<int> floyed(){
    memcpy(d, g, sizeof g);
    int minLen = INF;
    vector<int> res;
    int maxv = INF;
    for (int k = 1; k <= n; k ++){

        for (int i = 1; i < k; i ++){
            for (int j = i + 1; j < k; j ++){
                if((long long)d[i][j] + g[j][k] + g[k][i] < maxv){
                    vector<int> temp;
                    maxv = d[i][j] + g[j][k] + g[k][i];
                    temp.push_back(i);
                    get_path(i, j, temp);
                    temp.push_back(j);
                    temp.push_back(k);
                    res = temp;
                }
            }
        }

        

        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= n; j++)
            {
                if (d[i][j] > d[i][k] + d[j][k])
                {
                    d[i][j] = d[i][k] + d[j][k];
                    post[i][j] = k;
                }
            }
            }
    }
    return res;
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    scanf("%d%d", &n, &m);

 


    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i == j)
            {
                g[i][j] = 0;
            }
            else
            {
                g[i][j] = INF;
            }
        }
    }

    for (int i = 0; i < m; i ++){
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        g[b][a] = g[a][b] = min(g[a][b], c);
    }

    vector<int> res = floyed();

    if(res.size() == 0)
    {
        printf("No solution.\n");
    }else{
        for(int &a : res)
        {
            printf("%d ", a);
        }
    }

    return 0;
}